<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>狂神说</title>
    <!--1.导入vue.js axios.js-->
    <script src="https://cdn.jsdelivr.net/npm/vue@2.5.21/dist/vue.min.js"></script>
    <script src="https://unpkg.com/axios/dist/axios.min.js"></script>

    <!--v-clock:解决闪烁问题-->
    <style>
        [v-clock]{
            display: none;
        }
    </style>

</head>
<body>

<div id="app" v-cloak>
    <div>{{info.name}}</div>
    <div>{{info.address.street}}</div>

    <a v-bind:href="info.url">狂神说</a>
</div>

<script>
    let app = new Vue({
        el: '#app',

        //data()方法
        data(){
            return{
                //请求的返回参数格式，必须要和json字符串一样
                info:{
                    name: null,
                    url: null,
                    page: null,
                    isNonProfit: null,
                    address: {
                        street: null,
                        city: null,
                        country: null
                    }
                }
            }
        },
        methods: {//所有方法定义在methods里面
        },
        mounted(){ //钩子函数 链式编程 ES6新特性
            axios.get('../data.json').then(response=>(this.info=response.data));
        }
    });

</script>

</body>
</html>